<template>
    <div class="newsinfo-container">
        <h4 class="title">{{ newsInfo.title }}</h4>
        <p class="date">
          <span>发布时间: {{ newsInfo.add_time | dtFormat}}</span>
          <span>点击:{{ newsInfo.click }}次</span>
        </p>
        <hr>
        <div class="content" v-html="newsInfo.content"></div>
        <comment :id="id" ></comment> 
    </div>
</template>

<script>
import comment from "@/components/subcomponents/comment";
export default {
  data() {
    return {
      id: this.$route.params.id,
      newsInfo: {}
    };
  },
  components: {
    comment
  },
  created() {
    this.getnewsinfo();
  },
  methods: {
    async getnewsinfo() {
      const { data: res } = await this.$http.get("/api/getnew/" + this.id);
      if (res.status != 0) return Toast("请求数据失败！");
      this.newsInfo = res.message[0];
    }
  }
};
</script>

<style lang="scss" scoped>
.newsinfo-container {
  padding: 0 6px;
  .title {
    color: red;
    text-align: center;
    padding: 10px 0;
  }
  .date {
    display: flex;
    justify-content: space-between;
    color: #0094ff;
    margin: 0;
  }
  hr {
    margin: 0 0 5px;
  }
  .content {
    /deep/ img {
      width: 100%;
    }
  }
}
</style>
